if( SERVER ) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight	= 10
	SWEP.AutoSwitchTo = false
	SWEP.AutoSwitchFrom = false
end

if( CLIENT ) then
	SWEP.PrintName	= "Gun du Taulard"
	SWEP.Slot	= 1
	SWEP.SlotPos	= 2
	SWEP.DrawAmmo	= true
	SWEP.DrawCrosshair = true
	SWEP.ViewModelFOV = 62
	SWEP.ViewModelFlip = true
	killicon.AddFont( "weapon_gun_du_taulard", "CSKillIcons", "c", Color( 255, 80, 0, 255 ) )
end

SWEP.Base		= "weapon_base"

SWEP.Author		= "Enrico"
SWEP.Instructions	= ""
SWEP.Contact		= ""
SWEP.Purpose		= ""

SWEP.Primary.ClipSize = 12
SWEP.Primary.DefaultClip = 12
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "Pistol"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"

util.PrecacheSound("Weapon_Pistol.Single")
  
SWEP.ViewModel      = "models/weapons/v_pist_glock18.mdl"
SWEP.WorldModel   = "models/weapons/w_pist_glock18.mdl"

function SWEP:Initialize()
	if( SERVER ) then
		self:SetWeaponHoldType( "pistol" )
	end
end

function SWEP:Deploy()
	self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
	return true
end

function SWEP:PrimaryAttack()
	if !self:CanPrimaryAttack() then return end
	self.Weapon:SetNextPrimaryFire(CurTime()+0.1)
	self.Weapon:SetNextSecondaryFire(CurTime()+0.1)
	self.Owner:MuzzleFlash()
	self.Owner:SetAnimation( PLAYER_ATTACK1 )
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
	self.Weapon:EmitSound("Weapon_Pistol.Single")
	self:TakePrimaryAmmo( 1 )
	self.Owner:ViewPunch( Angle( math.Rand(-0.7,-0.4), math.Rand(-0.3,0.3), 0 ) )
	local bullet = {}
	bullet.Num 		= 1
	bullet.Src 		= self.Owner:GetShootPos()
	bullet.Dir 		= self.Owner:GetAimVector()
	bullet.Spread		= Vector( 0.02, 0.02, 0 )
	bullet.Tracer		= 4
	bullet.Force		= 5
	bullet.Damage		= 16
	self.Owner:FireBullets( bullet )
end

function SWEP:SecondaryAttack()
end

function SWEP:Reload()
	self.Weapon:DefaultReload( ACT_VM_RELOAD )
end

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )  
	draw.SimpleText( "c", "CSSelectIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end